package com.mvc.demo.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hh
 * @since 2023/11/11
 */
@RestController
@RequestMapping("jmeter")
public class TestJmeterController {


    @PostMapping("test")
    public Map<String, Object> test(@RequestBody Map<String, String> param) {
        HashMap<String, Object> resultMap = new HashMap<>();

        if ("1".equals(param.get("id"))) {
            resultMap.put("id", 1);
            resultMap.put("name", "张三");
            resultMap.put("age", 29);
            System.out.println(Thread.currentThread().getName() + ": 执行！");
            return resultMap;
        } else if ("2".equals(param.get("id"))) {
            resultMap.put("id", 2);
            resultMap.put("name", "李四");
            resultMap.put("age", 30);
            System.out.println(Thread.currentThread().getName() + ": 执行！");
            return resultMap;
        }
        return Collections.emptyMap();
    }
}
